home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
science
/
sm32a.zip
/
LIBRARY
/
LSOLVE.LI
< prev
next >
Wrap
Text File
|
1994-09-21
|
513b
|
10 lines
# lsolve() solve linear equations
# e.g. solve equations x+y-3=0 and x-y-1=0 for x and y
# lsolve(x+y-3, x-y-1, x,y) gives [x=2,y=1]
lsolve(eq1_, eq2_, x_, y_) := if(order(eq1,x)==1 and order(eq1,y)==1 and order(eq2,x)==1 and order(eq2,y)==1,
block(dd:=coef(eq1,x,1)*coef(eq2,y,1)-coef(eq1,y,1)*coef(eq2,x,1),
[ x=(coef(eq1,y,1)*coef(coef(eq2,x,0),y,0)-coef(coef(eq1,x,0),y,0)*coef(eq2,y,1))/dd,
y=-(coef(eq1,x,1)*coef(coef(eq2,x,0),y,0)-coef(coef(eq1,x,0),y,0)*coef(eq2,x,1))/dd ]),
local(dd))